package com.itheima.blackitheima;

import java.util.LinkedList;

public class LinkedTest {
    public static void main(String[] args) {
        //创建集合对象
        LinkedList<String> list=new LinkedList<>();
        list.add("aaaa");
        list.add("bbbb");
        list.add("cccc");
        list.add("dddd");
        list.add("eeee");

        //在首尾添加元素
        list.addFirst("hhh");
        list.addLast("zzz");
        System.out.println(list);

        //提取首尾元素
        String first = list.getFirst();
        System.out.println("first:"+first);
        String last = list.getLast();
        System.out.println("last:"+last);

        //删除首尾元素
        System.out.println(list);
        String s = list.removeFirst();
        System.out.println(s);
        System.out.println(list);
        String s1 = list.removeLast();
        System.out.println(s1);
        System.out.println(list);
    }
}
